package com.ternnetwork.auth.server.controller;


import com.ternnetwork.auth.server.service.WeChatAuthService;
import com.ternnetwork.commons.model.http.BaseResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * 微信授权
 * @author xuwenfeng
 *
 */
@RestController
public class WeChatAuthController {


	private final WeChatAuthService weChatAuthService;


	public WeChatAuthController(WeChatAuthService weChatAuthService) {
		this.weChatAuthService = weChatAuthService;

	}

	 @RequestMapping("/oauth/wechat/jsCodeToSession")
	 public  BaseResponse jsCodeToSession(@RequestParam(value="jsCode") String jsCode,@RequestParam(value="appId") String appId) {
		 Map resultMap=weChatAuthService.jsCodeToSession(jsCode,appId);
		 resultMap.remove("session_key");
		 BaseResponse baseResponse=new BaseResponse();
		 baseResponse.setSccucess(resultMap);
		 return baseResponse;
	 }




}
